package com.example.business.controller.admin;

import com.example.common.response.PageResponse;
import com.example.common.response.R;
import com.example.business.request.SbOrderListRequest;
import com.example.business.response.SbOrderResponse;
import com.example.business.service.SbOrderService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.business.request.SbOrderRequest;
import java.util.List;

@RestController
@RequestMapping("admin/sb-order")
public class SbOrderAdminController {
    @Autowired
    SbOrderService sbOrderService;

    @GetMapping("list")
    public R<PageResponse<SbOrderResponse>> list(@Valid SbOrderListRequest request) {
        PageResponse<SbOrderResponse> list = sbOrderService.list(request);
        return R.ok(list);
    }

    @PostMapping("save")
    public R<Object> save(@Valid @RequestBody SbOrderRequest request) {
        sbOrderService.save(request);
        return R.ok();
    }

    @DeleteMapping("delete")
    public R<Integer> delete(@RequestBody List<Long> ids) {
        int result = sbOrderService.deleteBatch(ids);
        return R.ok(result);
    }
}
